// run: time -p $exec < input
#include <iostream>

int const maxn = 100007;
int a[maxn], b[maxn];
int pos[maxn];
int ans[maxn];
bool vis[maxn];
int n;

std::pair<int, int> calc(int p, int d)
{
	std::pair<int, int> ret{-1, -1};
	int pb = pos[a[p]];
	if (d > std::max(n - a[p], a[p] - 1)) return ret;
	if (pb >= p) {
		int len = pb - p;
		if (d <= len) {
			ret.first = len - d;
			if (d <= p - 1) ret.second = len + d;
			return ret;
		} else if (d > len && p - 1 >= d) {
			ret.first = len + d;
			if (n - p >= d) ret.second = pb + n - p - d;
			return ret;
		} else return {pb + n - p - d , -1};
	} else {
		int len = p - pb;
		if (d >= len && d <= p - 1) {
			ret.first = d - len;
			if (d <= n - p) ret.second = pb + n - p - d;
			return ret;
		} else if (d >= len && n - p >= d) return {pb + n - p - d, -1};
		else {
			ret.first = n - (len - d);
			if (n - p >= d) ret.second = pb + n - p - d;
			return ret;
		}
	}
}

bool sorted()
{
	int i = 2;
	for (; i <= n; i++) if (a[i] < a[i - 1]) break;
	if (i <= n) {
		if (a[i - 1] != n || a[i] != 1) return false;
		for (i++; i <= n; i++) if (a[i] < a[i - 1]) return false;
	}

	i = 2;
	for (; i <= n; i++) if (b[i] < b[i - 1]) break;
	if (i <= n) {
		if (b[i - 1] != n || b[i] != 1) return false;
		for (i++; i <= n; i++) if (b[i] < b[i - 1]) return false;
	}
	return true;
}

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin >> n;
	for (int i = 1; i <= n; i++) std::cin >> a[i];
	for (int i = 1; i <= n; i++) {
		std::cin >> b[i];
		pos[b[i]] = i;
	}

	if (sorted()) {
		for (int i = 0; i <= n/2; i++) ans[i] = i;
		for (int i = 1; i <= n/2; i++) ans[n - i] = i;
		int t = n - pos[a[1]] + 1;
		for (int i = 0; i < n; i++)
			std::cout << ans[(i + t) % n] << '\n';
		return 0;
	}

	int count = 0;
	for (int i = 0; i <= n && count < n; i++) {
		for (int j = 1; j <= n && count < n; j++) {
			auto t = calc(j, i);
//			std::cout << ":: " << i << ' ' << j << ' ' << t.first << ' ' << t.second << '\n';
//			std::cout << "i = " << i << "  j = " << j <<  "  t = " << t << '\n';
			if (t.first != -1 && !vis[t.first]) {
				vis[t.first] = true;
				count++;
				ans[t.first] = i;
			}
			if (t.second == -1 || t.second >= n || vis[t.second]) continue;
			vis[t.second] = true;
			count++;
			ans[t.second] = i;
		}
	}
	for (int i = 0; i < n; i++)
		std::cout << ans[i] << '\n';
}

